﻿using NewsPortal.DataAccess.Abstraction;
using NewsPortal.Domain;
using NewsPortal.Domain.Layout;
using NewsPortal.Web.Infrastructure.BaseControllers;
using System;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Linq;

namespace NewsPortal.Web.Controllers
{
    public class GridController : EntityController<Grid>
    {
        public GridController(IUnitOfWork<Grid> unitOfWork)
        {
            this.UnitOfWork = unitOfWork;
            this.Repository = unitOfWork.Repository;
        }

        public async Task<ActionResult> Index()
        {
            Grid grid = await this.Repository.FirstAsync(new[] { "Rows.Columns" });
            
            return View();
        }

        [HttpGet]
        public ActionResult Create()
        {
            ViewBag.Pages = this.UnitOfWork.GetTypeRepository<Page>().All();
            
            return View(new Grid());
        }

        [HttpPost]
        public ActionResult Create(Grid grid)
        {
            throw new NotImplementedException();
        }
    }
}